function set_text_tinyMCE(id,texto){
	if (tinyMCE.getInstanceById(id) == null){
		xajax.$(id).value = texto;
	}
	else{
		var inst = tinyMCE.getInstanceById(id);
		inst.setHTML(texto);
	}
}

function get_text_tinyMCE(id){
	var txt = '';
	if (tinyMCE.getInstanceById(id) == null){
		txt = nl2br(xajax.$(id).value);
	}
	else{
		var inst = tinyMCE.getInstanceById(id);
		txt = inst.getHTML();
	}
	return txt;
}

function toggleEditor(id,anchor) {
	if (tinyMCE.getInstanceById(id) == null){
		tinyMCE.execCommand('mceAddControl', false, id);
		if(document.getElementById(anchor)){
			document.getElementById(anchor).innerHTML = 'Editor Simple';
		}
	}
	else{
		tinyMCE.execCommand('mceRemoveControl', false, id);
		if(document.getElementById(anchor)){
			document.getElementById(anchor).innerHTML = 'Editor Avanzado';
		}
	}
}

function radioChecked(id,value){
	var radios = document.getElementsByTagName('input');
	for(i=0;i<radios.length;i++){
		if(radios[i].getAttribute('type') == 'radio' && radios[i].getAttribute('id') == id && radios[i].getAttribute('value') == value){
			radios[i].checked = true;
		}
	}
}

function nl2br(str) {
   return str.replace(/\n/g,"<br />");
}

function voidNull(){
	$("a").each(function(){ if(this.href.substr(this.href.length - 1) == '#'){ this.href = 'javascript:void(null)';  } });
}
$('document').ready(voidNull);
